//
//  LGCultureHomeViewController.m
//  ligenyun
//
//  Created by Mac on 2018/3/27.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGCultureHomeViewController.h"
#import "TMGCultureHomeHeader.h"
#import "LGCultureHomeTableViewCell.h"
#import "LGCultureCommucateViewController.h"
#import "LGCultureOriginViewController.h"
@interface LGCultureHomeViewController ()<TMGCultureHomeHeaderDelegate>
@property(nonatomic, strong) TMGCultureHomeHeader                     *header;
@end

@implementation LGCultureHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"礼根文化";
    self.header = [[TMGCultureHomeHeader alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 20)];
    self.header.delegate = self;
    self.tableView.tableHeaderView = self.header;
    // Do any additional setup after loading the view.
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return [LGCultureHomeTableViewCell cellHeight];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 44;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * view = [TMUtils headerViewWithTitle:@"推荐阅读" moreButtonAction:^(UIButton *sender) {
        
    }];
    return view;
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    LGCultureHomeTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[LGCultureHomeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
    }
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.navigationController pushViewController:[LGCultureDetailViewController new] animated:YES];
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}

#pragma mark --TMGCultureHomeHeaderDelegate
- (void)cultureHomeHeader:(TMGCultureHomeHeader*)header onSelctedCommunicateArea:(NSString*)title{
    NSLog(@"点击了交流区的 %@",title);
    if ([title isEqualToString:@"文化交流"]) {
        [self.navigationController pushViewController:[LGCultureCommucateViewController new] animated:YES];
    }
}
- (void)cultureHomeHeader:(TMGCultureHomeHeader*)header onSelctedProductArea:(NSString*)title{
    NSLog(@"点击了保护区的 %@",title);
    if ([title isEqualToString:@"家谱文化"]) {
        [self.navigationController pushViewController:[LGCultureCommucateViewController new] animated:YES];
    }
    if ([title isEqualToString:@"百家起源"]) {
        [self.navigationController pushViewController:[LGCultureOriginViewController new] animated:YES];
    }
    if ([title isEqualToString:@"风水文化"]) {
        [self.navigationController pushViewController:[LGCultureCommucateViewController new] animated:YES];
    }
}

@end
